package blog.controller;

import blog.service.client.CollectClientService;
import blog.service.client.ThumbClientService;
import blog.vo.client.*;
import blog.vo.common.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 *
 */
@RestController
@RequestMapping("/collect")
public class CollectController {
    @Autowired
    private CollectClientService collectClientService;

    @PostMapping("/collect-count")
    public ResponseVO<Integer> collectCount(@RequestBody CollectCountVO collectCountVO){
        Integer collectCount = collectClientService.collectCount(collectCountVO);
        return new ResponseVO<Integer>(200,"ok",collectCount);
    }

    @PostMapping("/add-collect")
    public ResponseVO<Integer> addCollect(@RequestBody AddCollectVO addCollectVO){
        int result = collectClientService.addCollect(addCollectVO);
        if (result > 0){
            return new ResponseVO<Integer>(200,"ok",result);
        }
        else {
            return new ResponseVO<Integer>(200,"ok",result);
        }
    }

    @PostMapping("/is-add-collect")
    public ResponseVO<Integer> isAddCollect(@RequestBody CollectVO collectVO){
        int result = collectClientService.isAddCollect(collectVO);
        if (result == 0){
            return new ResponseVO<Integer>(200,"ok",0);
        }
        else {
            return new ResponseVO<Integer>(200,"ok",1);
        }
    }

    @PostMapping("/cancel-add-collect")
    public ResponseVO<Integer> cancelAddCollect(@RequestBody CollectVO collectVO){
        int result = collectClientService.cancelAddCollect(collectVO);
        if (result > 0){
            return new ResponseVO<Integer>(200,"ok",result);
        }
        else {
            return new ResponseVO<Integer>(200,"ok",result);
        }
    }
}
